﻿<UserControl xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"  x:Class="Skynet.SLAdministration.Views.MgmCategories.MgmCategoriesView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
    xmlns:cal="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation"
    xmlns:Helpers="clr-namespace:Infrastructure.Silverlight.Helpers;assembly=Infrastructure.Silverlight"
    mc:Ignorable="d"                 
             
             
    d:DesignHeight="300" d:DesignWidth="400"
              Name="MgmgCategoriesViewUC">
    <Grid x:Name="LayoutRoot">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        
        <Border  Grid.Row="0" Grid.Column="0"
                  Style="{StaticResource BrandingBorderStyle}">
            <StackPanel  Orientation="Horizontal" Style="{StaticResource LinksStackPanelStyle}">
                <HyperlinkButton Name="btnCreateCategory" Content="Create New Category" Style="{StaticResource LinkStyle}"  Command="{Binding NewCategoryCommand}"></HyperlinkButton>
                <HyperlinkButton Name="btnReloadCategory" Content="Reload" Style="{StaticResource LinkStyle}" Command="{Binding ReloadCommand}"></HyperlinkButton>     
            </StackPanel>            
        </Border>
        <sdk:DataGrid Grid.Column="0" Grid.Row="1" 
                      ItemsSource="{Binding    Path=CategoriesDataSource.Data}" AutoGenerateColumns="False"
                      CanUserSortColumns="True" CanUserReorderColumns="True" CanUserResizeColumns="True"
                      SelectionMode="Single">
            <sdk:DataGrid.Columns>
                <sdk:DataGridTemplateColumn Header="Delete">
                    <sdk:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Content="Delete" CommandParameter="{Binding}">
                                <Helpers:BindingHelper.Binding>
                                    <Helpers:BindingProperties TargetProperty="Command"
                                                               SourceProperty="DataContext"
                                                               Converter="{StaticResource AncetorPropertyConverter}"
                                                               ConverterParameter="DeleteCategoryCommand"
                                                               RelativeSourceAncestorType="DataGrid"></Helpers:BindingProperties>
                                </Helpers:BindingHelper.Binding>
                            </Button>                            
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellTemplate>                                    
                </sdk:DataGridTemplateColumn>
                <sdk:DataGridTemplateColumn Header="Detail">
                    <sdk:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Content="Detail" CommandParameter="{Binding}">
                                <Helpers:BindingHelper.Binding>
                                    <Helpers:BindingProperties TargetProperty="Command"
                                                               SourceProperty="DataContext"
                                                               Converter="{StaticResource AncetorPropertyConverter}"
                                                               ConverterParameter="ShowDetailCategoryCommand"
                                                               RelativeSourceAncestorType="DataGrid"></Helpers:BindingProperties>
                                </Helpers:BindingHelper.Binding>
                            </Button>
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellTemplate>
                </sdk:DataGridTemplateColumn>
                <sdk:DataGridTextColumn Binding="{Binding Title}" Header="Title" IsReadOnly="True"></sdk:DataGridTextColumn>
                <sdk:DataGridTextColumn Binding="{Binding Description}" Header="Description" IsReadOnly="True"></sdk:DataGridTextColumn>
            </sdk:DataGrid.Columns>            
        </sdk:DataGrid>
        
        




    </Grid>
</UserControl>
